package com.pay.controller;

import com.pay.common.response.Response;
import com.pay.common.util.CityCodeHelpUtil;
import com.pay.common.util.ExceptionHelpUtil;
import com.pay.manager.TestManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.function.Function;

@RestController
public class TestController {
    private static final Logger LOGGER = LoggerFactory.getLogger(TestController.class);

	@Autowired
	private TestManager testManager;

	@Autowired
	ExceptionHelpUtil exceptionHelpUtil;

	@Autowired
	CityCodeHelpUtil cityCodeHelpUtil;

	@RequestMapping("/test")
	public Response test1(@RequestBody Map<String, Object> paramMap) throws Exception{
		 new ArrayList<>().stream().map(e->e.equals("1")).count();

			return Response.success("helloword");
	}

//	@RequestMapping("/testdemo")
//	public Response test1(@RequestBody Map<String, Object> paramMap) throws Exception{
//		LOGGER.info("begin");
//		String account = CommonUtils.getValue(paramMap, "account");//平台账号
//		LOGGER.info("account-->"+account);
//		Account accountDto=testManager.getAcount(1L);
//		String rel =HttpClientUtils.getMethodGetResponse("http://www.baidu.com");
//		LOGGER.info("rel-->"+rel);
//		return Response.success("success", accountDto);
//	}
//
//	@RequestMapping(value = "/testdemo2", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
//	public Response test2(@RequestBody Map<String, Object> paramMap) {
//		LOGGER.info("begin2");
//		//城市编号测试
//		LOGGER.info("cityCodeQueryCityName-->"+cityCodeHelpUtil.cityCodeQueryCityName("8882"));
//		LOGGER.info("cityCodeQueryCityName-->"+cityCodeHelpUtil.cityCodeQueryCityName("111"));
//
//		LOGGER.info("cityNameQueryCityCode-->"+cityCodeHelpUtil.cityNameQueryCityCode("和静县"));
//		LOGGER.info("cityNameQueryCityCode-->"+cityCodeHelpUtil.cityNameQueryCityCode("asdfdd"));
//
//		LOGGER.info("cityCodeQueryProvinceCode-->"+cityCodeHelpUtil.cityCodeQueryProvinceCode("8882"));
//		LOGGER.info("cityCodeQueryProvinceCode-->"+cityCodeHelpUtil.cityCodeQueryProvinceCode("11111"));
//
//		LOGGER.info("cityNameQueryCityCode-->"+cityCodeHelpUtil.cityNameQueryProvinceCode("和静县"));
//		LOGGER.info("cityNameQueryCityCode-->"+cityCodeHelpUtil.cityNameQueryProvinceCode("asdfdd"));
//
//		String account="";
//		//异常测试
////		try {
//////			aaa();
////			account = CommonUtils.getValue(paramMap, "account");//平台账号
//////			String account1=null.toString();
////			int aa =1/0;
//////			new BusinessException("我是异常~~~~~~~~~~~~~~~");
////		}catch (Exception e1){
////			LOGGER.info("exception-->",e1);
////			exceptionHelpUtil.saveException(e1);
////			exceptionHelpUtil.saveException("TestController:test2:56",e1);
////			exceptionHelpUtil.saveException("TestController:test2:56",e1,"备注信息");
////		}
//		return Response.success("success2", account);
//	}
//
//	public void aaa() throws Exception{
//		throw  new BusinessException("我被抛出来了");
//	}

}
